package buzzword;

import java.util.ArrayList;
import java.util.List;

import json.JSONArray;
import json.JSONException;
import json.JSONObject;

public class WordList {
	
	private List<String> castJSONArrayToList(JSONArray wordArray) throws JSONException{
		List<String> wordList = new ArrayList<String>();
		for(int i = 0; i < wordArray.length(); i++){
			wordList.add(wordArray.getString(i));
		}
		return wordList;
		
		
	}
	
	private List<String> getWordList(String objectString) throws JSONException {
		JSONObject wordObject = new JSONObject(objectString);
		JSONArray wordArray = wordObject.getJSONArray("words");
		return castJSONArrayToList(wordArray);
	}
	
	public List<String> getWords(String JSONWords) throws JSONException {
		return getWordList(JSONWords);
	}




}
